package com.rfy.framework.util;

import java.util.concurrent.*;

/**
 *
 * @author: zhang
 * @date: 2019-03-25 14:21
 * @description：线程池工具类
 *
 */
public class ThreadPoolUtil {

    /**
     * 线程池 最小数量
     */
    private static final int COREPOOLSIZE = 10;

    /**
     * 线程池 最大数量
     */
    private static final int MAXIMUMPOOLSIZE = 90;

    /**
     * 保持活跃时间
     */
    private static final long KEEPALIVVETIME = 60000L;

    /**
     * 线程池
     */
    private static final ExecutorService executorServie = new ThreadPoolExecutor(
            COREPOOLSIZE, MAXIMUMPOOLSIZE, KEEPALIVVETIME, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>(), Executors.defaultThreadFactory());

    /**
     * 线程执行
     *
     * @param runnable
     */
    public static final void execute(Runnable runnable){
        executorServie.execute(runnable);
    }

}